package cn.xxxy.fourm.service.impl;

import java.util.ArrayList;
import java.util.List;

import javax.transaction.Transactional;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import cn.xxxy.fourm.dao.UserRoleDao;
import cn.xxxy.fourm.entity.UserRole;
import cn.xxxy.fourm.model.UserRoleDto;
import cn.xxxy.fourm.service.UserRoleService;
@Service@Transactional
public class UserRoleServiceImpl implements UserRoleService{
	@Autowired
	private UserRoleDao userRoleDao;
	
	@Override
	public List<UserRoleDto> listUserRoles() {
		List<UserRoleDto> lists1=new ArrayList<>();
		List<UserRole> lists=userRoleDao.findAll();
		for (UserRole userRole : lists) {
			UserRoleDto userRole1=new UserRoleDto();
			userRole1.setId(userRole.getRid());
			userRole1.setText(userRole.getRname());
			if(userRole.getRid()==1) {
				userRole1.setSelected(true);
			}else {
				userRole1.setSelected(false);
			}
			lists1.add(userRole1);
		}
		return lists1;
	}

}
